using System;
using System.Collections;
using System.Xml;

namespace Flaschengeist.DataAccess 
{
	public static class XmlRpcExtensions
	{		
		public static XmlNodeList GetRecord(this string xml)
		{		
			var document = new XmlDocument();
			document.LoadXml(xml);
			return document.DocumentElement.GetElementsByTagName("member");
		}
		
		public static XmlNodeList GetRecords(this string xml)
		{		
			var document = new XmlDocument();
			document.LoadXml(xml);
			return document.DocumentElement.GetElementsByTagName("struct");
		}
		
		public static string GetValueFromNode(this XmlNode node)
		{
			return (node != null && node.HasChildNodes) ? node.FirstChild.InnerText : string.Empty;
		}  
		
		public static string[] GetValuesFromNode(this XmlNode node)
        {
            var notes = GetValueFromNode(node);
            return string.IsNullOrEmpty(notes) ? new string[]{} : notes.Split('-'); 
        }
	}
}

